﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
        <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
            <c:set var="ctx" value="${pageContext.request.contextPath}" />
            <html>

            <head>
                <link rel="stylesheet" href="${ctx}/common/common.css">
                <title>Title</title>
                <link rel="stylesheet" href="${ctx}/common/plugins/layuiadmin/layui/css/layui.css" media="all">
                <link rel="stylesheet" href="${ctx}/common/plugins/layuiadmin/style/admin.css" media="all">
                <script src="${ctx}/common/plugins/layuiadmin/layui/layui.js"></script>

                <script src="${ctx}/common/plugins/jquery-1.10.2.min.js"></script>
            </head>

            <body>
                <form class="layui-form" action="${ctx}/department/saveDepartment">
                    <input type="hidden" name="id" id="departmentId" value="${department.id}" />
                    <div class="layui-form-item layui-col-md5" style="margin-top: 50px">
                        <label class="layui-form-label">父级部门</label>
                        <div class="layui-input-block" style="display: flex">
                            <input type="hidden" name="tDId" id="deptId" value="${department.tDId}" class="layui-input">
                            <input readonly id="dept" lay-type="showPerson" value="${parentDept.name}"
                                placeholder="请选择父级部门" autocomplete="off" class="layui-input">
                            <button type="button" class="layui-btn layui-btn-warm" id="clearButton"
                                lay-filter="clearDept">清空部门</button>
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-md5">
                        <label class="layui-form-label">部门名称<span style="color: red">*</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="name" value="${department.name}" lay-verify="required"
                                placeholder="请输入部门名称" autocomplete="on" class="layui-input">
                        </div>
                    </div>
                    <%-- <div class="layui-form-item layui-col-md5">
                        <label class="layui-form-label">编号<span style="color: red">*</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="code" value="${department.code}" lay-verify="required"
                                placeholder="请输入部门编号" autocomplete="on" class="layui-input">
                        </div>
                        </div>--%>
                        <div class="layui-form-item layui-col-md5">
                            <label class="layui-form-label">部门描述 </label>
                            <div class="layui-input-block">
                                <textarea type="text" name="described" value="${department.described}"
                                    placeholder="请输入部门描述信息" autocomplete="on" style="height: 200px;padding:10px;"
                                    class="layui-input"></textarea>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" id="formBtn" lay-submit lay-filter="formDemo">立即提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                                <button type="button" id="rollback" class="layui-btn layui-btn-primary">返回</button>
                            </div>
                        </div>
                </form>
                <script>
                    //Demo
                    var form = null;
                    layui.use('form', function () {
                        form = layui.form;
                        var $ = layui.$
                        //监听提交
                        form.on('submit(formDemo)', function (data) {
                            layer.load(1, {
                                shade: [0.1, '#fff'] //0.1透明度的白色背景
                            });
                            return true;
                        });
                        $("#clearButton").on("click", function () {
                            $("#deptId").val("")
                            $("#dept").val("")

                        })
                    });



                    document.getElementById("dept").addEventListener("click", function () {
                        layer.open({
                            type: 2,
                            skin: 'layui-layer-rim', //加上边框
                            area: ['30%', '80%'], //宽高
                            content: '${ctx}/department/queryMyDeptPage'
                        });
                        form.render();
                    })
                    document.getElementById("rollback").addEventListener("click", function () {
                        window.history.back();
                    })
                </script>
            </body>

            </html>